<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/pub/head.inc"%>
    <title>Node list</title>
</head>
<body>
  	<!-- Search Form -->
  	<div id="mainsearch" style=" width:98%">
	    <div class="searchtitle">
	        <span>搜索</span><img src="${baseURL}/themes/default/icons/32X32/searchtool.gif" />
	        <div class="togglebtn"></div> 
	    </div>
	    <div class="navline" style="margin-bottom:4px; margin-top:4px;"></div>
	    <div class="searchbox">
	        <form id="formsearch" class="l-form" method="get">
	        	<table>
					<tr>
						<td align="right" class="l-table-edit-td">${field.beanFieldDesc}</td>
						<td align="left" class="l-table-edit-td" style="width: 160px">
							<input  name="${field.beanFieldName}" type="text" ltype="${field.pageBeanFieldType}" class="field" />
						</td>
						<td align="left" class="l-table-edit-td">
							<button type="button" id="btnSearch" class="l-button l-button-submit"><i class="fa fa-search"></i> 搜索</button>
						</td>
						<td align="left" class="l-table-edit-td">
							<button type="reset" id="btnReset" class="l-button l-button-test" ><i class="fa fa-exchange"></i> 重置</button>
						</td>
					</tr>
				</table>
	        </form>
	    </div>
  	</div>
  	<!-- Search Form end -->
 	<!-- Grid List-->
	<div id="maingrid"></div> 
	<!-- Grid List end-->
  	<script type="text/javascript">
  		var baseUrl = '${baseURL}/node/node';

		//列表渲染
      	var grid = $("#maingrid").ligerGrid({ 
          	columns: [
				{display:"位置",name:"position",width:150,type:"text",align:"left",isSort : true},
				{display:"描述",name:"description",width:150,type:"text",align:"left",isSort : true},
				{display:"名称",name:"name",width:150,type:"text",align:"left",isSort : true},
				{display:"编码",name:"code",width:150,type:"text",align:"left",isSort : true}
   		  	],
          	dataAction: 'server',toolbar: {},
          	url:  baseUrl+'list/listJSON.do',
          	width: '98%', height: '100%',heightDiff:-10, checkbox: true,
          	pageParmName:"pageNo",pageSizeOptions:[${pageOptions}],pagesizeParmName:"perPageSize",
          	rowHeight:23,rownumbers:true,isScroll:true,sortnameParmName:"sortName",
          	sortorderParmName:"sortOrder",checkbox:true,pageSize: ${pageSize}
      	});
      	//搜索表单渲染
		$("#formsearch").ligerForm();
		
      	//加载工具栏
		LG.createToolbarButton(grid, [{id : "add", name : "新增", clickEvent : FF_AddClickEvent, icon : "/silkicons/add.png"},
      								{id : "modify", name : "修改", clickEvent : FF_ModifyClickEvent, icon : "/silkicons/application_edit.png"},
      								{id : "delete", name : "删除", clickEvent : FF_DeletedClickEvent, icon : "/silkicons/delete.png"}]);

		//双击事件
      	LG.setGridDoubleClick(grid, FF_ModifyClickEvent);
      	
	  	//搜索事件
      	$("#btnSearch").click(function(e){
    	  	var json = LG.bulidFilterParams($("#formsearch"));
          	grid.set('parms', json);
            //采用原来的请求地址，带上参数加载数据
		  	grid.loadData();
      	});
      	
  	   	//重置事件
     	$("#btnReset").click(function(e){
        	grid.set('parms', null);
            //采用原来的请求地址，带上参数加载数据
			grid.loadData();
      	});
	  
      	//新增方法
      	function FF_AddClickEvent(btnItem){
      		parent.f_addTab("NodeEdit", 'Node', baseUrl+'edit/edit.do?menuId=${param.menuId}');
      	}
    	
    	//修改方法
      	function FF_ModifyClickEvent(btnItem){
      		var row = grid.getLastSelected();
      		if (!row) { 
      			jQuery.ligerDialog.warn("请选择要修改的数据!"); 
      			return false;
      		}
      	    parent.f_addTab("NodeEdit", 'Node', baseUrl+'edit/edit.do?menuId=${param.menuId}&id=' + row.id);
      	}

		//删除方法
      	function FF_DeletedClickEvent(btnItem){
	      	var selectedRow = grid.getCheckedRows();
	      	if (!selectedRow || !selectedRow.length) {
	      		jQuery.ligerDialog.warn("请选选择要删除的数据!"); 
	      		return false;
	      	}
	      	jQuery.ligerDialog.confirm('您确定要删除吗?', function (confirm) {
	            if (!confirm)
	            	return false;
	            	
              	badousoft.ajax({
   					type: "GET",
   					url: baseUrl+"delete/delete.do",
   					dataType : "json",
   					data: "ids="+LG.serialIdParam(selectedRow),
   					beforeSend: function (){
		                LG.loading = true;
		                LG.showLoading('正在删除...');
		            },
		            complete: function (){
		                LG.loading = false;	  
		                LG.hideLoading();
		            },
   					success: function(msg){
     					if(msg && msg.hasOk){
     						grid.loadData();
     						jQuery.ligerDialog.success('删除成功!');
     					}else{
     						jQuery.ligerDialog.error("操作失败:\n" + msg.message + "\n请联系管理员!");
     					}
   					}
 				});
	        });
      	}
  	</script>
</body>
</html>